package com.barunsw.bwf.ems.neoarena.board;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.barunsw.bwf.ems.common.controller.CommonController;
import com.barunsw.bwf.ems.neoarena.model.Board;

@Controller
@RequestMapping
public class BoardController extends CommonController {
	private static final Logger LOGGER = LoggerFactory.getLogger(BoardController.class);
	
	@Autowired
	BoardService boardService;
	
	/**
	 * Board 리스트 조회
	 * 
	 * @param nodeId 조회하고자 하는 Node
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "/node/{nodeId}/board", method = RequestMethod.GET)
	public @ResponseBody List<Board> getBoardList(@RequestBody @PathVariable long nodeId) throws Exception {
		return boardService.getBoardList(nodeId);
	}

	/**
	 * Board 정보 조회
	 * 
	 * @param nodeId 조회하고자 하는 Node
	 * @param boardId 조회하고자 하는 Board
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "/node/{nodeId}/board/{boardId}", method = RequestMethod.GET)
	public @ResponseBody Board getBoard(@RequestBody @PathVariable long nodeId, @PathVariable int boardId) throws Exception {
		return boardService.getBoard(nodeId, boardId);
	}
}